#include "DataStructure/Input/Property/PBRSECTData.h"

#include <cstddef>
#include <cstring>
#include <string>

#include "DataStructure/Common/Validation.h"
#include "DataStructure/Input/Property/BeamSectionStandardTypes.h"

using namespace SG::DataStructure::FEM;

bool SG::DataStructure::FEM::operator== (const PBRSECTData::inpOrg& val1, const PBRSECTData::inpOrg& val2)
{
    FIELD_COMPARE (EXTID)
    FIELD_COMPARE (ID)
    return true;
}

bool SG::DataStructure::FEM::operator== (const PBRSECTData& val1, const PBRSECTData& val2)
{
    FIELD_COMPARE (m_id)

    for (size_t i = 0; i < val1.m_sections.size (); ++i)
    {
        const auto& secA = val1.m_sections[i];
        const auto& secB = val2.m_sections[i];

        if (!SG::DataStructure::Common::isNear (secA.OHEIGHT, secB.OHEIGHT))
        {
            return false;
        }

        if (!SG::DataStructure::Common::isNear (secA.OWIDTH, secB.OWIDTH))
        {
            return false;
        }

        for (size_t j = 0; j < secA.ings.size (); ++j)
        {
            if (!(secA.ings[j] == secB.ings[j]))
            {
                return false;
            }
        }

        for (size_t j = 0; j < secA.inps.size (); ++j)
        {
            if (!(secA.ings[j] == secB.ings[j]))
            {
                return false;
            }
        }
    }

    return true;
}